<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use App\Data\Category;
use App\Models\Attr;
use Illuminate\Contracts\View\View;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
//        View::composer([], function($view,$request)
//        {
//            $path = $request->get('path');
//            $pathClass = $this->path($path);
//            $thisCname = Category::where('path',$path)->select('cname')->get();
//            //通过获取到的父类path匹配所有的子类path
//            $cname = Category::where('path','like',$pathClass.'%')->get();
//            $id = $request->get('id');
//            //用ID匹配对应的cid，在用关联属性取到attrValue里面对应的值
//            $title = Attr::where('cid',$id)->with('attrValue')->get();
//            $attrs = [];
//            foreach ($title as $attr){
//                $attrs[] = $attr;
//            }
//            return view('home/goods/all_class')->with('attrs',$attrs)->with('cname',$cname)->with('thisCname',$thisCname);
//        });
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}
